﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;

namespace ProjectSem3
{
    public partial class WebForm7 : System.Web.UI.Page
    {
        private DataClassesHeaxlthDataContext dc = new DataClassesHeaxlthDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ImageButtonlogin_Click(object sender, ImageClickEventArgs e)
        {
            string username = this.TextBoxusername.Text;
            string password = this.TextBoxpassword.Text;
            EmpRegister emp;
            if (loginmember(username, password) != null)
            {
                string pass = mahoa_giaima.giaiMa(loginmember(username, password).password);
                if (pass == password)
                {
                    Response.Redirect("index.aspx");
                }
                else
                {
                    this.Labelkiemtra.Text = "Account Not found";
                }
            }
            else
            {
                this.Labelkiemtra.Text = "Account Not found";
            }

        }
        public EmpRegister loginmember(string username, string password)
        {
            EmpRegister emp = new EmpRegister();
            try
            {
                emp = this.dc.EmpRegisters.Where(em => em.username.Equals(username)).ToList().First();
                Session["member"] = emp;
            }
            catch
            {
                emp = null;
            }
            return emp;
        }
    }
}